<?php
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/AW-LICENSE-COMMUNITY.txt
 * 
 * =================================================================
 *                 MAGENTO EDITION USAGE NOTICE
 * =================================================================
 * This package designed for Magento COMMUNITY edition
 * aheadWorks does not guarantee correct work of this extension
 * on any other Magento edition except Magento COMMUNITY edition.
 * aheadWorks does not provide extension support in case of
 * incorrect edition usage.
 * =================================================================
 *
 * @category   AW
 * @package    AW_Vidtest
 * @copyright  Copyright (c) 2010-2011 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/AW-LICENSE-COMMUNITY.txt
 */
/**
 * Player renderer for backend area
 */
class AW_Vidtest_Model_Form_Element_Player extends Varien_Data_Form_Element_Text
{
    /**
     * Key for retrive API CODE
     */
    const REGISTRY_KEY = 'vidtest_api_code';

    /**
     * Retrives element html
     * @return string
     */
    public function getElementHtml()
    {       
        $apiCode = Mage::registry(self::REGISTRY_KEY);
        $videoUrl = $this->getValue();       
        if ($videoUrl && $apiCode){
            return Mage::getSingleton('vidtest/connector')
                        ->getApiModel($apiCode)
                        ->getRenderedPlayer($videoUrl, array('height' => '200px', 'width' => '317px'));
        }
        return '';
    }
}
